package wine.ejb.utilities;

import javax.naming.Context;
import javax.naming.InitialContext;

import wine.logic.bean.WSysUrlDao;
import wine.logic.interfaces.WSysUrlImpl;


public class LookupRemote{
	private WSysUrlDao wSysUrlDao = null;
	
	protected WSysUrlDao getWSysUrlDao(){
		if (!Utility.isNotEmpty(wSysUrlDao)) {
			wSysUrlDao = (WSysUrlDao) lookupDao(WSysUrlImpl.class);
		}
		return wSysUrlDao;
	}
	protected Object lookupDao(Class implClass) {
		try {
			Context ctx = new InitialContext();
			Log.debug(implClass.getSimpleName());
			return ctx.lookup(implClass.getSimpleName() + "/remote");
		} catch (Exception e) {
			// TODO: handle exception
			Log.error(e.getMessage());
			return null;
		}
	}
}